<?php

require_once 'Base.php';


class GoodsModel extends Base {
	
	//private $_table = "shop_goods";
	
	public function getList($where='', $page='',$pagesize=''){
		
		if($where) $this->where($where);
		//echo 
		
		if($pagesize) $this->limitPage($page,$pagesize);
		$temp=$this->select();
		//print_r($temp);
		return $this->select();
	}
	
	public function getone($where){
	 
	  $this->_db = $this->getAdapter();
    	$select = $this->_db->select();
    	$select->from($this->_table);
    	foreach ($where as $key => $val) {
            if (is_int($key)) {
               $select->where($val);
            } else {
               $select->where($key, $val);
            }
	     }   
	     
	   return $this->_db->fetchRow($select);
// 		 $this->where($where);
// 		 return $this->fetch();
		
		
	}
	
	public function getList2($where=''){
	
		$this->_db = $this->getAdapter();
    	$select = $this->_db->select();
    	$select->from('shop_goods',array('id','sellerid','goods_categoryid','name','sales','comment','costprice','currentprice','thumb'));
    	
	     foreach ($where as $key => $val) {
            if (is_int($key)) {
               
               $select->where($val);
            } else {
              
                $select->where($key, $val);
            }
	     }   
    	//if($pagesize) $select->limit($pagesize,$page*$pagesize); 
    	return $this->_db->fetchAll($select);
	}
}
